package cn.yunhe.servlet;

import cn.yunhe.entity.Product;
import cn.yunhe.service.ProductService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/GetProductServlet2")
public class GetProductServlet2 extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ProductService productServcie = new ProductService();
        //这个是获取热卖商品的数量
        List<Product> productSdtockList = productServcie.getSDtock();
        //促销商品
        List<Product> productMinList = productServcie.getMinPrice();
        request.setAttribute("productSdtockList",productSdtockList);
        request.setAttribute("productMinList",productMinList);
        request.getRequestDispatcher("index.jsp").forward(request,response);

    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
